<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    var num=[1,23,45,6,7];
    var min=max=num[0];
    for(var i=0;i<num.length;i++){
            if(min>num[i]){
                min=num[i];
            }
            if(max<num[i]){
                max=num[i];
            }
    }
    document.write("待排序数组："+num);
    document.write("最大值："+max+"   ");
    document.write("最小值："+min+'   ');
    console.log(max);
    console.log(min);
</script>
</body>
</html>